Skip to content

Add Queue::submit() for command buffer submission#1057

Merged
MarijnS95 merged 1 commit intollvm:mainfrom
Traverse-Research:queue-submit
Apr 28, 2026
Merged

Add Queue::submit() for command buffer submission#1057
MarijnS95 merged 1 commit intollvm:mainfrom
Traverse-Research:queue-submit

Conversation

@MarijnS95
Copy link
Copy Markdown
Collaborator

@MarijnS95 MarijnS95 commented Apr 2, 2026

Depends on #1033

Move command buffer submission logic from each backend's Device into Queue::submit(), which takes ownership of the command buffers. Each backend uses its Fence abstraction (#1007) for GPU synchronization:

  • Metal: commit() + waitUntilCompleted()
  • Vulkan: vkQueueSubmit() signaling a timeline semaphore (VulkanFence), then VulkanFence::waitForCompletion()
  • DX12: ExecuteCommandLists() + Queue::Signal() on the queue-owned DXFence, then DXFence::waitForCompletion()

Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

@MarijnS95 MarijnS95 force-pushed the queue-submit branch 2 times, most recently from b77026f to b8bd9ac Compare April 2, 2026 14:15
Comment thread lib/API/DX/Device.cpp Outdated
@MarijnS95

This comment was marked as resolved.

@MarijnS95 MarijnS95 force-pushed the queue-submit branch 5 times, most recently from 5e4f6d2 to 3b4f680 Compare April 13, 2026 15:09
@MarijnS95 MarijnS95 force-pushed the queue-submit branch 3 times, most recently from 0ed7539 to cfb2665 Compare April 14, 2026 15:04
@MarijnS95 MarijnS95 marked this pull request as draft April 14, 2026 15:25
@MarijnS95 MarijnS95 force-pushed the queue-submit branch 4 times, most recently from bdd258f to 83e0ad9 Compare April 16, 2026 17:31
@MarijnS95 MarijnS95 marked this pull request as ready for review April 17, 2026 12:13
@MarijnS95

This comment was marked as resolved.

Comment thread lib/API/DX/Device.cpp
Comment thread include/API/Device.h Outdated
Comment thread include/API/Device.h Outdated
Comment on lines +69 to +71
llvm::SmallVector<std::unique_ptr<CommandBuffer>> CBs;
CBs.push_back(std::move(CB));
return submit(std::move(CBs));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we do the above, then this SmallVector can have a fixed size of 1, rather than using a bunch of extra stack space here.

Suggested change
llvm::SmallVector<std::unique_ptr<CommandBuffer>> CBs;
CBs.push_back(std::move(CB));
return submit(std::move(CBs));
return submit(
llvm::SmallVector<std::unique_ptr<CommandBuffer>, 1>{std::move(CB)});

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to explicitly specify the size of N=1. However this move constructor doesn't seem to exist for unique_ptr:

 ...
 include/llvm/ADT/SmallVector.h:1254:11: note: in instantiation of member function
 'llvm::SmallVectorImpl<std::unique_ptr<offloadtest::CommandBuffer>>::append' requested here
  1254 |     this->append(IL);
       |           ^
 include/API/Device.h:70:9: note: in instantiation of member function
 'llvm::SmallVector<std::unique_ptr<offloadtest::CommandBuffer>, 1>::SmallVector' requested here
    70 |         llvm::SmallVector<std::unique_ptr<CommandBuffer>, 1>{std::move(CB)});
       |         ^
 include/c++/15.2.1/bits/unique_ptr.h:524:7: note: 'unique_ptr' has
 been explicitly marked deleted here
   524 |       unique_ptr(const unique_ptr&) = delete;
       |       ^

@MarijnS95 MarijnS95 force-pushed the queue-submit branch 2 times, most recently from a9c9641 to 53209e0 Compare April 23, 2026 12:39
@MarijnS95 MarijnS95 force-pushed the queue-submit branch 5 times, most recently from a0f8f7b to 5d6df25 Compare April 28, 2026 08:04
Move command buffer submission logic from each backend's Device into
Queue::submit(), which takes ownership of the command buffers. Each
backend uses its Fence abstraction for GPU synchronization:

- Metal: commit() + waitUntilCompleted()
- Vulkan: vkQueueSubmit() signaling a timeline semaphore (VulkanFence),
  then VulkanFence::waitForCompletion()
- DX12: ExecuteCommandLists() + Queue::Signal() on the queue-owned
  DXFence, then DXFence::waitForCompletion()

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@MarijnS95 MarijnS95 merged commit 8141eef into llvm:main Apr 28, 2026
10 of 12 checks passed
@MarijnS95 MarijnS95 deleted the queue-submit branch April 28, 2026 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants